/** 二分图最大匹配 */
#include <bits/stdc++.h>
using namespace std;
const int N = 510, M = 1e5 + 7;
int n1, n2, m;
int h[N], e[M], ne[M], idx;
int match[N];
bool st[N];
void add(int u, int v) { e[idx] = v, ne[idx] = h[u], h[u] = idx++; }
bool find(int x) {
  for (int i = h[x]; i != -1; i = ne[i]) {
    int j = e[i];
    if (!st[j]) {
      st[j] = true;
      if (match[j] == 0 || find(match[j])) {
        match[j] = x;
        return true;
      }
    }
  }
  return false;
}
int main() {
  cin >> n1 >> n2 >> m;
  memset(h, -1, sizeof h);
  while (m--) {
    int u, v;
    cin >> u >> v;
    add(u, v);
    // add(v, u);
  }
  int ans = 0;
  for (int i = 1; i <= n1; ++i) {  // Match each of them
    memset(st, 0, sizeof st);
    ans += find(i);
  }

  cout << ans << endl;
}
